package com.tqjc.system.core.config;

import com.tqjc.system.common.enums.pipeline.BusinessCode;
import com.tqjc.system.core.pipeline.ProcessMachine;
import com.tqjc.system.core.pipeline.ProcessTemplate;
import com.tqjc.system.core.pipeline.service.GetDetailTaskAction;
import com.tqjc.system.core.pipeline.service.SetTankCarPositionAction;
import com.tqjc.system.core.pipeline.service.CarExecuteTaskAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 86195
 * @version 1.0
 * @description 责任链配置类
 * @date 2023/11/1 9:56
 */
@Configuration
public class PipelineConfig {

    @Autowired
    private GetDetailTaskAction getDetailTaskAction;

    @Autowired
    private SetTankCarPositionAction setTankCarPositionAction;

    @Autowired
    private CarExecuteTaskAction carExecuteTaskAction;

    @Bean("addTaskTemplate")
    public ProcessTemplate addTaskPipeline(){
        ProcessTemplate addTaskTemplate = new ProcessTemplate();
        addTaskTemplate.setProcessList(Arrays.asList(getDetailTaskAction,setTankCarPositionAction,
                carExecuteTaskAction,setTankCarPositionAction, carExecuteTaskAction));
        return addTaskTemplate;
    }


    @Bean("processMachine")
    public ProcessMachine processMachine(){
        ProcessMachine processMachine = new ProcessMachine();
        Map map = new HashMap<String,ProcessTemplate>();
        map.put(BusinessCode.ADD_TASK_CODE.getCode(),addTaskPipeline());
        processMachine.setConfigMap(map);
        return processMachine;
    }





}
